import axiosInstance from '../interceptors'

// 用户登录
export const login = (data) => {
  return axiosInstance.post('/api/auth/login', data)
}

// 用户注册
export const register = (data) => {
  return axiosInstance.post('/api/auth/register', data)
}

// 获取用户信息
export const getUserInfo = () => {
  return axiosInstance.get('/api/auth/userinfo')
}

// 退出登录
export const logout = () => {
  return axiosInstance.post('/api/auth/logout')
}

// 刷新token
export const refreshToken = () => {
  return axiosInstance.post('/api/auth/refresh')
}

// 修改密码
export const changePassword = (data) => {
  return axiosInstance.post('/api/auth/change-password', data)
}

// 修改昵称
export const updateNickname = (data) => {
  return axiosInstance.post('/api/auth/update-nickname', data)
}

// 修改头像
export const updateAvatar = (data) => {
  return axiosInstance.post('/api/auth/update-avatar', data)
}

// 文件上传（头像上传）
export const uploadFile = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return axiosInstance.post('/api/file/upload-avatar', formData, {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}